function saveGroup(groupInfo) {
    return new Promise((resolve, reject) => {
        axios({
            method: 'post',
            url: '/amc/sys/base/group/save',
            baseURL: 'http://127.0.0.1:8098',
            headers: {'authorization': layui.data('user').token},
            data: groupInfo
        }).then((response)=>{
            let back = response.data
            resolve(back)
        }).catch(reason => {
            reject(reason)
        })
    });
}

function searchGroup(groupId) {
    return new Promise((resolve, reject) => {
        axios({
            method: 'get',
            url: '/amc/sys/base/group/search/'+groupId,
            baseURL: 'http://127.0.0.1:8098',
            headers: {'authorization': layui.data('user').token}
        }).then((response)=>{
            let back = response.data
            resolve(back)
        }).catch(reason => {
            reject(reason)
        })
    });
}

function updateGroup(groupInfo) {
    return new Promise((resolve, reject) => {
        axios({
            method: 'put',
            url: '/amc/sys/base/group/update/',
            baseURL: 'http://127.0.0.1:8098',
            headers: {'authorization': layui.data('user').token},
            data: groupInfo
        }).then((response)=>{
            let back = response.data
            resolve(back)
        }).catch(reason => {
            reject(reason)
        })
    });
}

function deleteGroups(groupInfos) {
    return new Promise((resolve, reject) => {
        axios({
            method: 'delete',
            url: '/amc/sys/base/group/deletes/',
            baseURL: 'http://127.0.0.1:8098',
            headers: {'authorization': layui.data('user').token},
            data: groupInfos
        }).then((response)=>{
            let back = response.data
            resolve(back)
        }).catch(reason => {
            reject(reason)
        })
    });
}

function searchGroupOfAgency(agencyCode) {
    return new Promise((resolve, reject) => {
        axios({
            method: 'get',
            url: '/amc/sys/base/group/search/by/'+agencyCode,
            baseURL: 'http://127.0.0.1:8098',
            headers: {'authorization': layui.data('user').token}
        }).then((response)=>{
            let back = response.data
            resolve(back)
        }).catch(reason => {
            reject(reason)
        })
    });
}

function assignedRoles(roleinfos, groupId) {
    return new Promise((resolve, reject) => {
        axios({
            method: 'put',
            url: '/amc/sys/base/group/assign/role/'+groupId,
            baseURL: 'http://127.0.0.1:8098',
            headers: {'authorization': layui.data('user').token},
            data: roleinfos
        }).then((response)=>{
            let back = response.data
            resolve(back)
        }).catch(reason => {
            reject(reason)
        })
    });
}